package com.example.oa;

import javax.servlet.ServletContextAttributeEvent;
import javax.servlet.ServletContextAttributeListener;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import javax.servlet.annotation.WebListener;

@WebListener
public class ApplicationListenerTest implements ServletContextListener, ServletContextAttributeListener {
    @Override
    public void contextInitialized(ServletContextEvent sce) {
        System.out.println("context Initialized: 应用程序启动");
    }

    @Override
    public void contextDestroyed(ServletContextEvent sce) {
        System.out.println("context Destroyed: 应用程序关闭");
    }

    @Override
    public void attributeAdded(ServletContextAttributeEvent event) {
        System.out.println("application attribute added: " + event.getName() + "->" + event.getValue());
    }

    @Override
    public void attributeRemoved(ServletContextAttributeEvent event) {
        System.out.println("application attribute removed: " + event.getName() + "->" + event.getValue());
    }

    @Override
    public void attributeReplaced(ServletContextAttributeEvent event) {
        System.out.println("application attribute replaced: " + event.getName() + "->" + event.getValue());
    }
}
